package com.suzj.extraenchantments.datagen;


import com.suzj.extraenchantments.ExtraEnchantments;
import com.suzj.extraenchantments.item.ItemRegistry;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.RegistryObject;


public class ModItemModelProvider extends ItemModelProvider {

    public ModItemModelProvider(PackOutput generator, ExistingFileHelper existingFileHelper) {
        super(generator, ExtraEnchantments.MODID, existingFileHelper);
    }

    @Override
    protected void registerModels() {

        for (var item : ItemRegistry.ITEMS.getEntries()) {
            if (item.get() instanceof BlockItem) {
                ExtraEnchantments.LOGGER.info("block item will not gen");
            } else {
                itemWithModel(item, "item/generated");
            }
        }

    }

    public void itemWithModel(RegistryObject<Item> registryObject, String model) {
        ResourceLocation id = registryObject.getId();
        ResourceLocation textureLocation = ResourceLocation.fromNamespaceAndPath(id.getNamespace(), "item/" + id.getPath());
        singleTexture(id.getPath(), ResourceLocation.parse(model), "layer0", textureLocation);
    }

}
